//根据Host，获得当前站点的域名
function getLangs() {
    var host = window.location.host;
    var _langs = host.substring(0, host.indexOf('.'));
    if (_langs == "www") _langs = "en";
    return _langs;
}
//End 根据Host，获得当前站点的域名
var showWindown = true;
//模块的目录
var templateSrc = "";
function tipsWindown(title, content, width, height, drag, time, showbg, cssName, backgroundsrc) {
    $("#windown-box").remove();
    var width = width >= 950 ? this.width = 950 : this.width = width;
    var height = height >= 527 ? this.height = 527 : this.height = height;
    if (showWindown == true) {
        var simpleWindown_html = new String;
        simpleWindown_html = "<div id=\"windownbg\" style=\"height:" + $(document).height() + "px;filter:alpha(opacity=0);opacity:0;z-index: 999901\"></div>";
        simpleWindown_html += "<div id=\"windown-box\">";
        simpleWindown_html += "<div id=\"windown-title\"><h2></h2><span id=\"windown-close\">关闭</span></div>";
        simpleWindown_html += "<div id=\"windown-content-border\"><div id=\"windown-content\"></div></div>";
        simpleWindown_html += "</div>";
        $("body").append(simpleWindown_html);
        show = false
    }
    contentType = content.substring(0, content.indexOf(":"));
    content = content.substring(content.indexOf(":") + 1, content.length);
    switch (contentType) {
        case "text":
            $("#windown-content").html(content);
            break;
        case "id":
            $("#windown-content").html($("#" + content + "").html());
            break;
        case "img":
            $("#windown-content").ajaxStart(function () {
                $(this).html("<img src='" + templateSrc + "/images/loading.gif' class='loading' />")
            });
            $.ajax({ error:function () {
                $("#windown-content").html("<p class='windown-error'>加载数据出错...</p>")
            }, success:function (html) {
                $("#windown-content").html("<img src=" + content + " alt='' />")
            } });
            break;
        case "url":
            var content_array = content.split("?");
            $("#windown-content").html("<img src='" + templateSrc + "/images/loading.gif' class='loading' />");
            $.ajax({ type:content_array[0], url:content_array[1], data:content_array[2], error:function () {
                $("#windown-content").html("<p class='windown-error'>加载数据出错...</p>")
            }, success:function (html) {
                $("#windown-content").html(html)
            } });
            break;
        case "iframe":
            $("#windown-content").html("");
            $("#windown-content").append("<iframe name='windown_iframe' id='windown_iframe' onload='javascript:$(\"#windown-loading\").hide();iFrameHeight();' src=\"" + content + "\" width=\"100%\" height=\"" + parseInt(height) + "px" + "\" scrolling=\"no\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
    }
    $("#windown-title h2").html(title);
    if (showbg == "true") {
        $("#windownbg").show()
    } else {
        $("#windownbg").remove()
    }
    ;
    $("#windownbg").animate({ opacity:"0.5" }, "normal");
    $("#windown-box").show();
    if (height >= 527) {
        $("#windown-title").css({ width:(parseInt(width) + 27) + "px" });
        $("#windown-content").css({ width:(parseInt(width) + 17) + "px", height:"auto" })
    } else {
        $("#windown-title").css({ width:(parseInt(width) + 10) + "px" });
        $("#windown-content").css({ width:width + "px", height:"auto" })
    }
    var cw = document.documentElement.clientWidth, ch = document.documentElement.clientHeight, est = document.documentElement.scrollTop;
    var _version = $.browser.version;
    if ($.browser.msie && _version == 6.0) {
        $("#windown-box").css({ left:"50%", top:(parseInt((ch) / 2) + est) + "px", marginTop:-((parseInt(height) + 53) / 2) + "px", marginLeft:-((parseInt(width) + 32) / 2) + "px", zIndex:"999999" })
    } else {
        $("#windown-box").css({ left:"50%", top:"50%", marginTop:-((parseInt(height) + 53) / 2) + "px", marginLeft:-((parseInt(width) + 32) / 2) + "px", zIndex:"999999" })
    }
    ;
    var Drag_ID = document.getElementById("windown-box"), DragHead = document.getElementById("windown-title");
    var moveX = 0, moveY = 0, moveTop, moveLeft = 0, moveable = false;
    if (_version == 6.0) {
        moveTop = est
    } else {
        moveTop = 0
    }
    var sw = Drag_ID.scrollWidth, sh = Drag_ID.scrollHeight;
    DragHead.onmouseover = function (e) {
        if (drag == "true") {
            DragHead.style.cursor = "move"
        } else {
            DragHead.style.cursor = "default"
        }
    };
    DragHead.onmousedown = function (e) {
        if (drag == "true") {
            moveable = true
        } else {
            moveable = false
        }
        e = window.event ? window.event : e;
        var ol = Drag_ID.offsetLeft, ot = Drag_ID.offsetTop - moveTop;
        moveX = e.clientX - ol;
        moveY = e.clientY - ot;
        document.onmousemove = function (e) {
            if (moveable) {
                e = window.event ? window.event : e;
                var x = e.clientX - moveX;
                var y = e.clientY - moveY;
                if (x > 0 && (x + sw < cw) && y > 0 && (y + sh < ch)) {
                    Drag_ID.style.left = x + "px";
                    Drag_ID.style.top = parseInt(y + moveTop) + "px";
                    Drag_ID.style.margin = "auto"
                }
            }
        };
        document.onmouseup = function () {
            moveable = false
        };
        Drag_ID.onselectstart = function (e) {
            return false
        }
    };
    $("#windown-content").attr("class", "windown-" + cssName);
    var closeWindown = function () {
    
        $("#windownbg").remove();
        $("#windown-box").fadeOut("slow", function () {
            $(this).remove()
        })
    };
    
    
    if (time == "" || typeof (time) == "undefined") {
    	 
$("#windown-close").click(function () {
        	
            $("#windownbg").remove();
            $("#windown-box").fadeOut("slow", function () {
            	
                $(this).remove()
            })
        });
 
    }
  else {
   
        setTimeout(closeWindown, time)
    }
    
}

//ifame自适应高度,被包含的页面，内部有影响页面长度的要在页面中完成操作好再次调用这个方法。如:parent.iFrameHeight();
function iFrameHeight() {
    //set current page title
    document.title=(document.getElementById('windown_iframe').contentWindow.document.title);
    var ifm = document.getElementById("windown_iframe");
    var subWeb = document.frames ? document.frames["windown_iframe"].document : ifm.contentDocument;
    if (ifm != null && subWeb != null) {
        var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;
        if(isChrome) {
            ifm.height = subWeb.documentElement.scrollHeight;
        }else {
            ifm.height = subWeb.body.scrollHeight  ;
        }
    }
}










